<template>
  <div style="padding:30px;">
    <div class="title">库存盘点表</div>
    <el-table :data="tableData" style="width: 100%;margin-top: 50px" border>
      <el-table-column label="编号" width="200" type="index">
      </el-table-column>
      <el-table-column label="物资名称" width="250">
        <template slot-scope="scope">{{ scope.row.name }}</template>
      </el-table-column>
      <el-table-column label="规格" width="250">
        <template slot-scope="scope">{{ scope.row.model }}</template>
      </el-table-column>
      <el-table-column label="生产厂家" width="250">
        <template slot-scope="scope">{{ scope.row.manufacturer }}</template>
      </el-table-column>
      <el-table-column label="单价（元）" width="250">
        <template slot-scope="scope">{{ scope.row.price }}</template>
      </el-table-column>
      <el-table-column label="库存数量（单位）" width="230">
        <template slot-scope="scope">{{ scope.row.total }}</template>
      </el-table-column>
      <el-table-column label="盘点数量" width="202">
      </el-table-column>
    </el-table>
    <div class="total">盘点总金额：{{ Math.round(totalAmount*100)/100 }} 元</div>
  </div>
</template>
    
<script>
import { getAllMaterialsVo } from "@/api/outform"
export default {
  data() {
    return {
      tableData: [],
      totalAmount: 0
    };
  },
  created() {
    this.getAllMaterialsVo()
  },
  methods: {
    // 获取物资列表
    async getAllMaterialsVo() {
        let res = await getAllMaterialsVo()
        console.log(res.data.data)
        this.tableData = res.data.data
        this.totalAmount = this.tableData.reduce((pre, cur) => {
            return pre + cur.price * cur.total
        },0)
      },
    onSubmit() {
      console.log("submit!");
    }
  }
};
</script>

<style>
.title {
  text-align: center;
  font-size: 20px;
  font-weight: bold;
}

.total {
  color: #5f5f5f;
  line-height: 50px;
}
</style>